package com.vito.dcs.asphalt.asphaltMonitor.action;


import com.vito.base.authoriza.cache.SessionMap;
import com.vito.base.authoriza.model.UserModel;
import com.vito.base.model.ResMsg;
import com.vito.dcs.asphalt.asphaltMonitor.model.AlarmAsphaltModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.authoriza.action.BaseAction;
import com.vito.base.model.Result;
import com.vito.dcs.asphalt.asphaltMonitor.service.AlarmAsphaltService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 沥青摊铺压实报警 接口
 */
@Controller
@RequestMapping("/dcs/asphalt/alarmAsphaltAction")
public class AlarmAsphaltAction extends BaseAction {

    private static final Logger log = LoggerFactory.getLogger(AlarmAsphaltAction.class);

    @Reference
    private AlarmAsphaltService alarmAsphaltService;

    /**
     *  根据标段ID获取沥青监控列表数据
     * @param
     * @return
     */
    @RequestMapping("queryAlarmAsphaltList")
    @ResponseBody
    public Result queryAlarmAsphaltList(AlarmAsphaltModel alarmAsphaltModel){
        Result res = new Result();
        try {
            UserModel user = SessionMap.getObj();
            if (null == user) {
                res.setCode(Result.CODE_LOGIN_REQUIRE);
                res.setMsg(ResMsg.MSG_LOGIN_NEED);
                return res;
            }
            if(alarmAsphaltModel.getSectionId() != null && !"".equals(alarmAsphaltModel.getSectionId())){
                res.setData(alarmAsphaltService.queryAlarmAsphaltModelList(alarmAsphaltModel));
                res.setCode(Result.CODE_OK);
            }else{
                res.setCode(Result.CODE_ERROR);
                res.setMsg(ResMsg.EXECERR);
            }
        }catch (Exception ex){
            log.error("查询失败",ex);
            res.setCode(Result.CODE_ERROR);
            res.setMsg(ResMsg.EXECERR);
        }
        return  res;
    }
}
